package com.example.wallpaperapp.widget;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.example.wallpaperapp.R;

/**
 * 倒计时TextView
 * 发送验证码后变为倒计时
 */

public class CountDownTextView extends CountDownTimer {
    private TextView textView;
    private Context context;

    public CountDownTextView(long millisInFuture, long countDownInterval, TextView textView, Context context) {
        super(millisInFuture, countDownInterval);
        this.textView=textView;
        this.context=context;
    }

    @Override
    public void onTick(long l) {
        textView.setClickable(false);
        textView.setText(l/1000+"秒后重新发送");
        textView.setTextColor(context.getResources().getColor(R.color.gray_hint));
    }

    @Override
    public void onFinish() {
        textView.setClickable(true);
        textView.setText("重新获取验证码");
        textView.setTextColor(context.getResources().getColor(R.color.black));
    }
}